/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package mvp.levelup.lists;

import java.util.Iterator;
import java.util.LinkedList;

/**
 *
 * @author WORKSPOT2
 */
public class LinkedListMain
{
    public static void main(String[] args){
        LinkedList<String> linkList = new LinkedList<String>();
        linkList.add("String1");
        linkList.add("String2");
        linkList.add("String3");
        linkList.add("String4");
        linkList.add("String5");
        linkList.add(4, "String0");

        Iterator<String> iter = linkList.iterator();
        String tmp;
        int i = 0;
        while (iter.hasNext() && i < 4)
        {
            tmp = iter.next();
            if (i == 3)
            {
                iter.remove();
            }
            i++;
        }

        iter = linkList.iterator();
        while (iter.hasNext())
        {
            tmp = iter.next();
            System.out.println(tmp);
        }

        for (String tmp1 : linkList)
        {
            
            System.out.println(tmp1);
        }

    }
}
